/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package desktopapplication1;

import java.util.*;

/**
 *
 * @author TEST - na podstawie: http://introcs.cs.princeton.edu/java/23recursion/MapOfProbabilities.java.html
 */
public class MapOfProbabilities {

    private Map<String,Double> mapOfProbabilities = new HashMap<String,Double>();
    private Random generator = new Random();
    
    
    public MapOfProbabilities(int n) {
        gray("", n);
    }
    
    
    public Map<String,Double> getMapOfProbabilities () {
        return mapOfProbabilities;
    }
    
    private void yarg(String prefix, int n) {
        if (n == 0) mapOfProbabilities.put(prefix, generator.nextDouble());
        else {
            gray(prefix + "D", n - 1);
            yarg(prefix + "C", n - 1);
        }
    }  
    
    private void gray(String prefix, int n) {
        if (n == 0) mapOfProbabilities.put(prefix, generator.nextDouble());
        else {
            gray(prefix + "C", n - 1);
            yarg(prefix + "D", n - 1);
        }
    }      

}
